/*
 * Created on 19.mar.2005
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
package gui.domain;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;

import controller.Controller;

public class Mainmenu extends JMenuBar implements ActionListener {
	String g = "TEXT";
	Boolean b;

	// list of global menuitems, accessible in several methods
	JMenuItem open = new JMenuItem("load");
	JMenuItem save = new JMenuItem("save");
	JMenuItem exit = new JMenuItem("exit");
	JMenuItem paste = new JMenuItem("paste");
	JMenuItem test = new JMenuItem("test");
	JMenuItem view = new JMenuItem(g);
	
	public void skift(){
			g="HTML";
	}
	

	public Mainmenu() {

		// list of verticals
		JMenu file = new JMenu("file");
		JMenu edit = new JMenu("edit");
		JMenu tools = new JMenu("tools");
		JMenu search = new JMenu("search");
		JMenu windows = new JMenu("windows");
		JMenu help = new JMenu("help");
		//JMenu view = new JMenu("view");

		// file
		file.add(open).addActionListener(this);
		file.add(save).addActionListener(this);
		file.add(exit).addActionListener(this);

		// edit
		edit.add(paste).addActionListener(this);
		

		// tools
		tools.add(test).addActionListener(this);

		// windows
		windows.add(view).addActionListener(this);

		// help

		add(file);
		add(edit);
		add(tools);
		add(search);
		add(windows);
		add(help);
		//add(view);
	}

	public void actionPerformed(ActionEvent arg) {
		if (arg.getSource() == open)
			Controller.open();
		if (arg.getSource() == save)
			Controller.save();
		if (arg.getSource() == exit)
			Controller.stop();
		if (arg.getSource() == paste)
			Controller.paste();
		if (arg.getSource() == test)
			Controller.testhtml();
		if (arg.getSource() == view)
			Controller.view();
			if (b==true){
				skift();
				b=false;
			}
		
	}

}
